package com.siwei.mes.entity.system;

import cn.dev33.satoken.stp.StpUtil;
import com.siwei.mes.common.validator.AddGroup;
import com.siwei.mes.common.validator.UpdateGroup;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;

import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;


/**
 * 含水率(AggregateWater)实体类
 *
 * @author linzi
 * @since 2023-12-01 22:37:51
 */
@Data
@Accessors(chain = true)
@Table(name = "pk_aggregate_water")
@ApiModel(value = "AggregateWater", description = "含水率")
public class AggregateWater implements Serializable {
    private static final long serialVersionUID = 447397972000324053L;
    /**
     * 主键id
     */
    @Id
    @ApiModelProperty(value = "含水率主键ID", name = "id")
    @NotNull(groups = {UpdateGroup.class}, message = "主键id为空")
    private Long id;
    /**
     * 操作时间
     */
    @Column(name = "oper_time")
    @ApiModelProperty(value = "操作时间", name = "operTime")
    @NotNull(groups = {AddGroup.class, UpdateGroup.class}, message = "操作时间为空")
    private Date operTime;
    /**
     * 细骨料烘前试样重
     */
    @Column(name = "fine_aggregate_before")
    @ApiModelProperty(value = "细骨料烘前试样重", name = "fineAggregateBefore")
    @NotBlank(groups = {AddGroup.class, UpdateGroup.class}, message = "细骨料烘前试样重为空")
    private String fineAggregateBefore;
    /**
     * 细骨料烘后试样中
     */
    @Column(name = "fine_aggregate_after")
    @ApiModelProperty(value = "细骨料烘后试样中", name = "fineAggregateAfter")
    @NotBlank(groups = {AddGroup.class, UpdateGroup.class}, message = "粗骨料烘后试样中为空")
    private String fineAggregateAfter;
    /**
     * 细骨料含水率
     */
    @Column(name = "fine_aggregate_water")
    @ApiModelProperty(value = "细骨料含水率", name = "fineAggregateWater")
    @NotBlank(groups = {AddGroup.class, UpdateGroup.class}, message = "粗骨料含水率为空")
    private String fineAggregateWater;
    /**
     * 粗骨料烘前试样重
     */
    @Column(name = "coarse_aggregate_before")
    @ApiModelProperty(value = "粗骨料烘前试样重", name = "coarseAggregateBefore")
    @NotBlank(groups = {AddGroup.class, UpdateGroup.class}, message = "粗骨料烘前试样重为空")
    private String coarseAggregateBefore;
    /**
     * 粗骨料烘后试样中
     */
    @Column(name = "coarse_aggregate_after")
    @ApiModelProperty(value = "粗骨料烘后试样中", name = "coarseAggregateAfter")
    @NotBlank(groups = {AddGroup.class, UpdateGroup.class}, message = "粗骨料烘后试样中为空")
    private String coarseAggregateAfter;
    /**
     * 粗骨料含水率
     */
    @Column(name = "coarse_aggregate_water")
    @ApiModelProperty(value = "粗骨料含水率", name = "coarseAggregateWater")
    @NotBlank(groups = {AddGroup.class, UpdateGroup.class}, message = "粗骨料含水率为空")
    private String coarseAggregateWater;
    /**
     * 试验人
     */
    @Column(name = "test_person")
    @ApiModelProperty(value = "试验人", name = "testPerson")
    @NotBlank(groups = {AddGroup.class, UpdateGroup.class}, message = "试验人为空")
    private String testPerson;
    /**
     * 创建人
     */
    @Column(name = "creater")
    @ApiModelProperty(value = "创建人", name = "creater")
    private Long creater;
    /**
     * 创建时间
     */
    @Column(name = "create_time")
    @ApiModelProperty(value = "创建时间", name = "createTime")
    private Date createTime;
    /**
     * 修改人
     */
    @Column(name = "updater")
    @ApiModelProperty(value = "修改人", name = "updater")
    private Long updater;
    /**
     * 更新时间
     */
    @Column(name = "update_time")
    @ApiModelProperty(value = "更新时间", name = "updateTime")
    private Date updateTime;
    /**
     * 是否删除  1-删除
     */
    @Column(name = "is_del")
    @ApiModelProperty(value = "是否删除  1-删除", name = "isDel")
    private Integer isDel;

    @Transient
    @ApiModelProperty(value = "开始时间")
    private String startTime;

    @Transient
    @ApiModelProperty(value = "结束时间")
    private String endTime;

    public AggregateWater init(boolean isCreate) {
        this.setUpdater(StpUtil.isLogin() ? StpUtil.getLoginIdAsLong() : null).setUpdateTime(new Date());
        if (isCreate) {
            this.setCreater(StpUtil.isLogin() ? StpUtil.getLoginIdAsLong() : null).setCreateTime(new Date()).setIsDel(0);
        }
        return this;
    }
}
